﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SSharp.Core.Builtins.Functions.Util {
	public static class ThreadSafeRandom {
		private static readonly object seedLocker = new Object();
		private static readonly Random seedGenerator = new Random();
		[ThreadStatic]
		private static Random rng;

		public static Random getRng() {
			if (rng == null) {
				lock (seedLocker) {
					rng = new Random(seedGenerator.Next());
				}
			}
			return rng;
		}
	}
}
